$(function(){
    //product category tree view 
    $("#product_category_tree").treeview();
    
    //Handle when choose an item from treeview to add new product category.
    $('#product_category_tree li span').click(function(){
        $('#product_category_tree span.category-text').removeClass('product-category-select');
        $(this).children()
                .filter('.category-text')
                .addClass('product-category-select');
    });
    
    //Dialog delete.
    $('#dialog_del_product_category').dialog({
        autoOpen: false, 
        modal:true,
        width:400,
        height:300,
        buttons: {
            Delete: function(){
                $('#dialog_del_product_category').dialog('close');
            },
            Cancel: function(){
                $('#dialog_del_product_category').dialog('close');
            }
            
        }
    });
    
    $('#product_category_tree a.delete').click(function(){
        $('#dialog_del_product_category').dialog('open');
    });
});

